package util

import (
	"copper-cloud/pkg/setting"
	"github.com/gin-gonic/gin"
	"github.com/unknwon/com"
)

// GetPage get page parameters
func GetPage(c *gin.Context) (int, int){

	pageNum := com.StrTo(c.Query("pageNum")).MustInt()
	pageSize := com.StrTo(c.Query("pageSize")).MustInt()

	// 如果没有传pageSize，默认设置为10
	if pageSize == 0 {
		pageSize = setting.AppSetting.PageSize
	}

	if pageNum > 0 {
		pageNum = (pageNum - 1) * pageSize
	}

	return pageNum, pageSize
}